/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background-color: #f8f8f8;
    color: #333;
    line-height: 1.6;
}

/* 头部导航栏 */
header {
    background-color: white;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 1px 10px rgba(0, 0, 0, 0.05);
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
}

.header-container h1 {
    font-size: 1.5rem;
    color: #fe2c55;
}

nav ul {
    display: flex;
    list-style: none;
    gap: 20px;
}

nav a {
    text-decoration: none;
    color: #333;
    font-size: 0.95rem;
    transition: color 0.2s;
}

nav a:hover {
    color: #fe2c55;
}

.welcome-message {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 0.9rem;
}

.logout-link {
    color: #999;
    text-decoration: none;
    font-size: 0.85rem;
}

.logout-link:hover {
    color: #fe2c55;
}

/* 个人资料容器 */
.profile-container {
    max-width: 1000px;
    margin: 2rem auto;
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    overflow: hidden;
}

/* 个人资料头部 */
.profile-header {
    display: flex;
    align-items: center;
    padding: 2rem;
    border-bottom: 1px solid #f0f0f0;
}

.avatar-container {
    margin-right: 2rem;
    text-align: center;
    position: relative;
}

.user-avatar {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    object-fit: cover;
    border: 5px solid white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 1rem;
    transition: transform 0.3s;
}

.user-avatar:hover {
    transform: scale(1.03);
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    outline: none;
}

#changeAvatarBtn {
    background-color: #fe2c55;
    color: white;
    margin-bottom: 0.5rem;
}

#changeAvatarBtn:hover {
    background-color: #e02a4b;
    transform: translateY(-1px);
}

/* 个人资料信息 */
.profile-info h2 {
    font-size: 1.6rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #333;
}

.profile-info p {
    color: #666;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

.post-stats {
    display: flex;
    gap: 2rem;
    margin-bottom: 1rem;
}

.post-stats span {
    color: #333;
    font-size: 1.1rem;
    font-weight: 500;
}

.post-stats span::before {
    content: attr(data-label) ': ';
    color: #999;
    font-weight: normal;
}

/* 个人资料内容 */
.profile-content {
    padding: 2rem;
}

/* 个人简介 */
.profile-bio {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid #f0f0f0;
}

.profile-bio h3 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #333;
}

.profile-bio p {
    color: #666;
    line-height: 1.7;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

#bioForm {
    margin-top: 1rem;
}

#bioText {
    width: 100%;
    padding: 12px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    resize: vertical;
    margin-bottom: 1rem;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.3s;
}

#bioText:focus {
    border-color: #fe2c55;
}

#editBioBtn {
    background-color: #f0f0f0;
    color: #333;
}

#editBioBtn:hover {
    background-color: #e0e0e0;
}

/* 用户帖子 */
.user-posts h3 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: #333;
}

.post-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}

.user-post-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 1/1;
    background-color: #f0f0f0;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
}

.user-post-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.post-media {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.post-media img,
.post-media video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.user-post-item:hover .post-media img,
.user-post-item:hover .post-media video {
    transform: scale(1.05);
}

.post-meta {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px 10px;
    background-color: rgba(0,0,0,0.6);
    color: white;
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    opacity: 0;
    transition: opacity 0.3s;
}

.user-post-item:hover .post-meta {
    opacity: 1;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .profile-header {
        flex-direction: column;
        text-align: center;
        padding: 1.5rem;
    }
    
    .avatar-container {
        margin-right: 0;
        margin-bottom: 1.5rem;
    }
    
    .user-avatar {
        width: 120px;
        height: 120px;
    }
    
    .post-stats {
        justify-content: center;
        gap: 1.5rem;
    }
    
    .post-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    
    .profile-content {
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    .profile-container {
        margin: 0;
        border-radius: 0;
    }
    
    .post-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 4px;
    }
    
    .profile-header,
    .profile-content {
        padding: 1rem;
    }
    
    .post-stats {
        gap: 1rem;
    }
    
    .post-stats span {
        font-size: 1rem;
    }
}

.header-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.header-actions {
    margin: 10px 0 20px 0;
}

/* 返回首页按钮样式 */
.back-home-btn {
    margin-right: 1rem;
    font-weight: bold;
    padding: 0.6rem 1.2rem;
}

/* 确保在header-container中正确布局 */
.header-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.back-home-btn:hover {
    background-color: #45a049;
}

/* 确保导航菜单在按钮下方正确显示 */
nav {
    width: 100%;
}

nav ul {
    display: flex;
    justify-content: center;
    list-style: none;
    padding: 0;
}

nav ul li {
    margin: 0 15px;
}

/* 确保个人资料列表样式美观 */
.profile-details-list {
    list-style: none;
    padding: 0;
    margin: 15px 0;
}

.profile-details-list li {
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

.profile-details-list li:last-child {
    border-bottom: none;
}

/* 确保返回首页导航链接样式与主页一致 */
.back-home-nav {
    color: inherit;
    text-decoration: none;
    padding: 0.5rem 1rem;
    display: block;
    transition: background-color 0.3s ease;
}

.back-home-nav:hover {
    background-color: #f0f0f0;
}